package com.album.web.util;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;

/**
 * @Description: 封装
 * @Author Ray
 * @Date 2020/5/20 0020 9:54
 * @Version 1.0
 */
public class Result implements Serializable {

    private static final String DEFAULT_SUCCESS_MESSAGE = "保存成功";
    private static final String GET_DATA_SUCCESS_MESSAGE = "获取数据成功";

    private int code;
    private String msg;
    private long count;
    private Object data;

    public Result(String msg) {
        this.msg = msg;
    }

    public Result(Object data) {
        this.msg = DEFAULT_SUCCESS_MESSAGE;
        this.data = data;
    }

    public Result(String msg, Object data) {
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public Result setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public Result setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public long getCount() {
        return count;
    }

    public Result setCount(long count) {
        this.count = count;
        return this;
    }

    public Object getData() {
        return data;
    }

    public Result setData(Object data) {
        this.data = data;
        return this;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
